<?php
namespace Admin\Controller;
use Think\Controller;
class BigMoneyController extends IndexController{
    public function lists(){
        $this->display();
    }

    public function get_list(){
        $BigMoney=D("Bigmoney_yhk");
        if(I("request.iDisplayStart")==''){

            $start=0;
        }else{
            $start=I("request.iDisplayStart");
        }


        if(I("request.sSearch")!=''){
            $where['cart_name'] = array('like','%'.I("request.sSearch").'%');;
        }else{
            $where='';
        }

        $result= $BigMoney->where($where)->limit($start,I("request.iDisplayLength"))->select();
        if($result){
            $BandCard=D("Bandcard_class");
            $band=$BandCard->field('id,name')->select();
            //把card_class_id 字段换成银行卡名称
            $arr=array();
            foreach($result as $key=>$value){
                $arr[$key]=$value;
                foreach($band as $k=>$v){
                    if($v['id']==$arr[$key]['cart_class_id']){
                        $arr[$key]['cart_class_id']=$v['name'];//换成银行名称
                        $arr[$key]['is_status']=$arr[$key]['is_status']==0?'不可用':'可用';
                        $arr[$key]['create_time']=date("Y年m月d日 H:i:s",$arr[$key]['create_time']);
                        $arr[$key]['update_time']=$arr[$key]['update_time']!="" ? date("Y年m月d日 H:i:s",$arr[$key]['update_time']):"";
                    }
                }
            }


            $ret = array(
                "sEcho" => intval($_GET['sEcho']),
                "iTotalRecords" => $start,
                "iTotalDisplayRecords" => $BigMoney->count(),
                "aaData" =>$arr
            );
            echo json_encode($ret);exit;

        }else{
            echo json_encode(0); eixt;
        }
    }


}